package com.example.demo.rabbitmq.topic;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 鱼仔
 * @date 2021/7/1 4:37 下午
 * 订阅/发布模式的生产者
 */
@Component
public class TopicSender {

    @Resource
    private AmqpTemplate amqpTemplate;

    private static final String exchangeName = "test.topic.exchange";

    public void topicSend(String msg, String routingKey) {
        amqpTemplate.convertAndSend(exchangeName, routingKey, msg);
    }
}
